/**
	The Minerva Project, DAG Scheduling Tools
	Copyright (C) 2006 Florin Pop & Stefan Bucur

	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
 */

package ro.pub.cs.minerva.task;

import java.io.Serializable;

import ro.pub.cs.minerva.graph.GraphNode;

/**
 * @author Florin Pop
 *
 */
public class Task extends GraphNode implements Serializable {
	
	private static final long serialVersionUID = 200701031624L;
	
	private int userId;
	private String taskId;
	private String path;
	private long arrivingTime;
	private String arguments;
	private String input;
	private String output;
	private String error;
	private TaskRequirements taskReqs;
	private int nrexec;
	
	/**
	 * 
	 */
	public Task() {
		super();
	}
	
	/**
	 * @param taskId
	 * @param userId
	 * @param path
	 * @param arrivingTime
	 * @param arguments
	 * @param input
	 * @param output
	 * @param error
	 * @param taskReqs
	 * @param nrexec
	 */
	public Task(String taskId, int userId, String path, long arrivingTime, String arguments, String input, String output, String error, TaskRequirements taskReqs, int nrexec) {
		this.taskId = taskId;
		this.userId = userId;
		this.path = path;
		this.arrivingTime = arrivingTime;
		this.arguments = arguments;
		this.input = input;
		this.output = output;
		this.error = error;
		this.taskReqs = taskReqs;
		this.nrexec = nrexec;
	}
	
	/**
	 * @return the arguments
	 */
	public String getArguments() {
		return arguments;
	}

	/**
	 * @param arguments the arguments to set
	 */
	public void setArguments(String arguments) {
		this.arguments = arguments;
	}

	/**
	 * @return the arrivingTime
	 */
	public long getArrivingTime() {
		return arrivingTime;
	}

	/**
	 * @param arrivingTime the arrivingTime to set
	 */
	public void setArrivingTime(long arrivingTime) {
		this.arrivingTime = arrivingTime;
	}

	/**
	 * @return the error
	 */
	public String getError() {
		return error;
	}

	/**
	 * @param error the error to set
	 */
	public void setError(String error) {
		this.error = error;
	}

	/**
	 * @return the input
	 */
	public String getInput() {
		return input;
	}

	/**
	 * @param input the input to set
	 */
	public void setInput(String input) {
		this.input = input;
	}

	/**
	 * @return the nrexec
	 */
	public int getNrexec() {
		return nrexec;
	}

	/**
	 * @param nrexec the nrexec to set
	 */
	public void setNrexec(int nrexec) {
		this.nrexec = nrexec;
	}

	/**
	 * @return the output
	 */
	public String getOutput() {
		return output;
	}

	/**
	 * @param output the output to set
	 */
	public void setOutput(String output) {
		this.output = output;
	}

	/**
	 * @return the path
	 */
	public String getPath() {
		return path;
	}

	/**
	 * @param path the path to set
	 */
	public void setPath(String path) {
		this.path = path;
	}

	/**
	 * @return the taskId
	 */
	public String getTaskId() {
		return taskId;
	}

	/**
	 * @param taskId the taskId to set
	 */
	public void setTaskId(String taskId) {
		this.taskId = taskId;
	}

	/**
	 * @return the taskReqs
	 */
	public TaskRequirements getTaskReqs() {
		return taskReqs;
	}

	/**
	 * @param taskReqs the taskReqs to set
	 */
	public void setTaskReqs(TaskRequirements taskReqs) {
		this.taskReqs = taskReqs;
	}

	/**
	 * @return the userId
	 */
	public int getUserId() {
		return userId;
	}

	/**
	 * @param userId the userId to set
	 */
	public void setUserId(int userId) {
		this.userId = userId;
	}
	
	//public String toString(){ return new String(""+taskId); }
	
	public int getTaskCost() {
		return 10;
	}

	@Override
	public Object clone() throws CloneNotSupportedException {
		Task result = (Task)super.clone();
		
		result.taskReqs = (TaskRequirements)taskReqs.clone();
		
		return super.clone();
	}

	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof Task))
			return false;
		
		Task task = (Task)obj;
		
		if (this.taskId.equals(task.taskId))
			return true;
		else
			return false;
	}
	
	public String toString(){
		return new String("[userId="+userId+",taskId="+taskId+",path="+
				path+",arrivingTime="+arrivingTime+",arguments="+arguments+",input="+input+",output="+
				output+",error="+error+",requirements="+taskReqs.toString()+",nrexec="+nrexec+"]");
	}
	
}
